package esi.t2no1.jobs;

import org.project.t2rk2.ParseException_Exception;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import org.springframework.scheduling.quartz.QuartzJobBean;

import esi.t2no1.ws.Ws;

/**
 * 
 * @author Reimo Rebane
 * 
 */
public class ReportLoadProfileSharesJob extends QuartzJobBean {

	private static final org.slf4j.Logger LOG = org.slf4j.LoggerFactory
			.getLogger(ReportLoadProfileSharesJob.class);

	@Override
	protected void executeInternal(JobExecutionContext context)
			throws JobExecutionException {

		// Send profile shares of T2ES1
		System.out.println("Send load profile shares of T2ES1");
		// Send to T2RK1
		Ws.T2RK1.receiveLoadProfileShare(Ws.NETWORK_OWNER_ID, "T2ES1", "T2RK1",
				"2", "3", "4", "5", "6");

		// Send to T2RK2
		try {
			Ws.T2RK2.saveLoadProfileShare(Ws.NETWORK_OWNER_ID, "T2ES1",
					"T2RK2", "2", "3", "4", "5", "6");
		} catch (ParseException_Exception e) {
			LOG.error("Failed to parse load profile shares to T2RK2 message format");
		}

		// Send load profile of T2ES2
		System.out.println("Send load profile shares of T2ES2");
		// Send to T2RK1
		Ws.T2RK1.receiveLoadProfileShare(Ws.NETWORK_OWNER_ID, "T2ES2", "T2RK1",
				"2", "3", "4", "5", "6");

		// Send to T2RK2
		try {
			Ws.T2RK2.saveLoadProfileShare(Ws.NETWORK_OWNER_ID, "T2ES2",
					"T2RK2", "2", "3", "4", "5", "6");
		} catch (ParseException_Exception e) {
			LOG.error("Failed to parse load profile shares to T2RK2 message format");
		}
	}
}
